import { MessageBlock } from "../../../../../Framework/MQ/MessageBlock";
import { SerializeStream } from "../../../../../Framework/Serialize/SerializeStream";
import { SEntityInfo } from "../../../../../Message/BroadCast/SEntityInfo";
import { SSeqEntityInfo } from "../../../../../Message/BroadCast/SSeqEntityInfo";
import { SEntityMoveInfo } from "../../../../../Message/BroadCast/SEntityMoveInfo";
import { SEntityId } from "../../../../../Message/Public/SEntityId";
import { SSeqEntityIdInfo } from "../../../../../Message/BroadCast/SSeqEntityIdInfo";
import { SEntityUpdate } from "../../../../../Message/BroadCast/SEntityUpdate";
import { SBeginFight } from "../../../../../Message/BroadCast/SBeginFight";
import { SDoFight } from "../../../../../Message/BroadCast/SDoFight";
import { SDoFights } from "../../../../../Message/BroadCast/SDoFights";
import { SEntityIdPair } from "../../../../../Message/Public/SEntityIdPair";
import { EntityUtil } from "../../../scene/layer/utils/EntityUtil";
import { RolePlayer } from "../../../scene/player/entity/RolePlayer";
type int = number;
//class TimeMB
    
    export  class TimeMB
    {
        constructor()
        {
            
            this.mb = new MessageBlock();
            return;
        }

        public read(arg1: SerializeStream): void
        {
            this.time = arg1.readInt();
            this.mb.__read(arg1);
            this.changeRoleMsg();
            return;
        }

        /* internal  */changeRoleMsg(): void
        {
            var loc2=null;
            var loc3=null;
            var loc4=null;
            var loc5=null;
            var loc6=null;
            var loc7=null;
            var loc1=this.mb.messageBase;
            if (typeof loc1 === "sentityinfo") 
            {
                loc3 = loc1 as SEntityInfo;
                this.changeRoleEntityId(loc3.entityId);
            }
            else if (typeof loc1 === "sseqentityinfo") 
            {
                loc4 = (loc1 as SSeqEntityInfo).entityInfos;
                var loc8=0;
                var loc9=loc4;
                for(loc3 of loc9) 
                {
                    this.changeRoleEntityId(loc3.entityId);
                }
            }
            else if (typeof loc1 === "sentitymoveinfo") 
            {
                this.changeRoleEntityId((loc1 as SEntityMoveInfo).entityId);
            }
            else if (typeof loc1 === "sentityid") 
            {
                this.changeRoleEntityId(loc1 as SEntityId);
            }
            else if (typeof loc1 === "sseqentityidinfo") 
            {
                loc5 = (loc1 as SSeqEntityIdInfo).entityIds;
                loc8 = 0;
                loc9 = loc5;
                for(loc2 of loc9) 
                {
                    this.changeRoleEntityId(loc2);
                }
            }
            else if (typeof loc1 === "sentityupdate") 
            {
                this.changeRoleEntityId((loc1 as SEntityUpdate).entityId);
            }
            else if (typeof loc1 === "sbeginfight") 
            {
                this.changeRoleEntityId((loc1 as SBeginFight).fromEntity);
                loc6 = (loc1 as SBeginFight).toEntitys;
                loc8 = 0;
                loc9 = loc6;
                for(loc2 of loc9) 
                {
                    this.changeRoleEntityId(loc2);
                }
            }
            else if (typeof loc1 === "sdofight") 
            {
                this.changeRoleEntityId((loc1 as SDoFight).entity);
                this.changeRoleEntityId((loc1 as SDoFight).fromEntity);
            }
            else if (typeof loc1 === "sdofights") 
            {
                loc8 = 0;
                loc9 = (loc1 as SDoFights).doFights;
                for(loc7 of loc9) 
                {
                    this.changeRoleEntityId(loc7.entity);
                    this.changeRoleEntityId(loc7.fromEntity);
                }
            }
            else if (typeof loc1 === "sentityidpair") 
            {
                this.changeRoleEntityId((loc1 as SEntityIdPair).fromEntityId);
                this.changeRoleEntityId((loc1 as SEntityIdPair).toEntityId);
            }
            return;
        }

        /* internal  */changeRoleEntityId(arg1: SEntityId): void
        {
            if (EntityUtil.equal(arg1, RolePlayer.instance.entityInfo.entityInfo.entityId)) 
            {
                arg1.id = int.MAX_VALUE;
            }
            return;
        }

        public /* var */time: int;

        public /* var */mb: MessageBlock;
    }
